﻿		var timeout=0;
		var ActiveMenu=null;
		var ActiveButton=null;
		var imgover=null;
     	function getRealLeft(el) {
			xPos = el.offsetLeft;
			tempEl = el.offsetParent;
			while (tempEl != null) {
				xPos += tempEl.offsetLeft;
				tempEl = tempEl.offsetParent;
			}
			return xPos;
		}     	
		function getRealTop(el) {
			yPos = el.offsetTop;
			tempEl = el.offsetParent;
			while(tempEl != null){
				yPos += tempEl.offsetTop;
				tempEl = tempEl.offsetParent;
			}
			return yPos;
		}
		function OnOffHyber(){
			timeout=setTimeout("OffHyber()",600);
		}
		function offHyberItem(item){
			item.className = "topMenuItemOff";
			timeout = setTimeout("OffHyber()", 300);
		}
		function OffHyber(){
		    	//if(ActiveButton != null) ActiveButton.className = "imgOut";
				if(ActiveMenu != null) ActiveMenu.style.visibility = "hidden";
				ActiveButton = null;
				ActiveMenu = null;
		}
		function OnOverHyberLink(button,_id){
		//Parent button
	        button.style.visibility='visible';
		//neu Activebutton da duoc kick hoat
			//if (ActiveButton!=null) ActiveButton.className="imgOut";
		//neu ActiveMenu ton tai (khac rong)
			if (ActiveMenu!=null) ActiveMenu.style.visibility="hidden";
			clearTimeout(timeout);
			ActiveButton=button;
			//ActiveButton.className="imgOver"; 
			ActiveMenu=document.getElementById("img" + _id);
			if (ActiveMenu!=null)	{
				ActiveMenu.style.visibility="visible"; 
				ActiveMenu.style.left = getRealLeft(button)+ 62;
				ActiveMenu.style.top = getRealTop(button)+ 2;
			}
		}
		//An hien comboBox
		function showSelects(){
           var elements = document.getElementsByTagName("select");
           for (i=0;i< elements.length;i++){
              elements[i].style.visibility='visible';
              elements[i].style.display='block';
           }
        }
        //thuc hien hide cai combo di
        function hideSelects(){
           var elements = document.getElementsByTagName("select");
           for (i=0;i< elements.length;i++){
            elements[i].style.visibility='hidden';
            elements[i].style.display='none';
           }
        }
		function OnOverImage(button,id){
		//neu Activebutton da duoc kick hoat
			if (ActiveButton!=null) ActiveButton.className="btOff";
		//neu ActiveMenu ton tai (khac rong)
			if (ActiveMenu!=null) ActiveMenu.style.visibility="hidden";
			clearTimeout(timeout);
			ActiveButton=button;
			ActiveButton.className="btOn"; 
			ActiveMenu=document.getElementById(ActiveButton.id + id);
			if (ActiveMenu!=null)	{
				ActiveMenu.style.visibility="visible"; 
				ActiveMenu.style.left = getRealLeft(button)-14;
				ActiveMenu.style.top = getRealTop(button)-10;
			}
		}
		function OnOffImage(){
			timeout=setTimeout("Off()",300);
		}
		function Off(){
		    	if(ActiveButton != null) ActiveButton.className ="btOff";
				if(ActiveMenu != null) ActiveMenu.style.visibility = "hidden";
				ActiveButton = null;
				ActiveMenu = null;
		}
		function onTopMenuItem(item){
			clearTimeout(timeout);
			item.className = "topMenuItemOn";
			window.status =item.statustext;     
		}
		
		function offTopMenuItem(item){
			item.className = "topMenuItemOff";
			timeout = setTimeout("Off()", 300);
		}
		function ClickLink(url){
			document.location=url; 
		}
		//===================================
	function imgOver(src) {
	    clearTimeout(timeout);			
		src.style.visibility="visible";
		src.style.cursor='hand';
		imgover=src;
	}
	function imgOut(){
	  timeout=setTimeout("iOut()",600);
	}
	function iOut(src) {
      imgover.style.visibility = "hidden";
      imgover.style.cursor='normal';
	}
	function luachon(the_site)
	{
		window.document.location.href=the_site;
	}
	function Status(status)
	{
		window.status=status;
	}
	function StatusOff(status)
	{
		window.status="";
	}
    function openPicture(img)
    {
	    window.open("picture.aspx?image=" + img,"Image","width=800,height=600,resizable=yes,scrollbars=yes,toolbar=no,top=40,left=100");		
    }			
    function openImage(img)
    {
	    window.open("viewImage.aspx?image=" + img,"Image","width=800,height=600,resizable=yes,scrollbars=yes,toolbar=no,top=40,left=100");		
    }
    function OpenImage(path)
    {
        var drag;
        drag=document.all("Drag");
        var img=document.all("_image");
        if (drag!=null) {
           drag.style.visibility='visible';
           drag.style.display='block';
 	       drag.style.left=document.body.scrollLeft+document.body.clientWidth/2-drag.offsetWidth/2;
 	       window_onscroll();
        }
        if (img!=null)
        img.src="viewImage.aspx?image="+path;
    }
    function OpenImage1(path)
    {
        var drag;
        drag=document.all("ImgDrag");
        //var img=document.all("_image");
        if (drag!=null) {
           drag.style.display='block';
 	       drag.style.left=document.body.scrollLeft+document.body.clientWidth/2-drag.offsetWidth/2;
 	      // window_onscroll();
        }
        //if (img!=null)
        //img.src="viewImage.aspx?image="+path;
    }
    function ViewNews(strPath)
    {
        var drag;
        drag=document.all("Drag");
        //drag.style.width=400;
        //drag.style.height=350;
        var img=document.all("_image");
        if (drag!=null) {
           drag.style.visibility='visible';
           drag.style.display='block';
 	       drag.style.left=document.body.scrollLeft+document.body.clientWidth/2-drag.offsetWidth/2;
        }
        if (img!=null)
        img.src=strPath;
    }
    function openhelp(strPath)
    {
        var drag;
        drag=document.all("Drag1");
        //drag.style.width=400;
        //drag.style.height=350;
        var img=document.all("_image1");
        if (drag!=null) {
           drag.style.visibility='visible';
           drag.style.display='block';
 	       drag.style.left=document.body.scrollLeft+document.body.clientWidth/2-drag.offsetWidth/2;
        }
        if (img!=null)
        img.src=strPath;
    }
    function Close(){
        var drag;
        drag=document.all("Drag");
        if (document.all('Drag')!=null){
          drag.style.visibility='hidden';
          drag.style.display='none';
        }
    }
    function _Close(){
        var drag;
        drag=document.all("ImgDrag");
        if (document.all('ImgDrag')!=null){
          drag.style.display='none';
        }
    }
 function Close1(){
        var drag;
        drag=document.all("Drag1");
        if (document.all('Drag1')!=null){
          drag.style.visibility='hidden';
          drag.style.display='none';
        }
    }    function MsgBox(text){
       return window.confirm(text);
    }
    function Filechange(obj)
    {
        _image= document.all["ViewImg"];
        var _height,_width;        
        _width=_image.width;
       _height=_image.height;
        if (_height>180)
        {
          iheight=180;
          _percent=_height/iheight
          iwidth=_width/_percent;
          document.all["ViewImg"].width=iwidth;
          document.all["ViewImg"].height=iheight;
        _image.src=obj.value;  
        }else if(_width>180)
         {
            iwidth=180;
            _percent=_width/iwidth
            iheight=_height/_percent;
            document.all["ViewImg"].width=iwidth;
            document.all["ViewImg"].height=iheight;
           _image.src=obj.value;  
         }  
    }
    function changeSize(sPath,Image)
    {
      var  _image= document.all["ViewImg"];    
      _image.src=sPath + sImage;
      var  _height,_width;
      _width=_image.width;
      _height=_image.height;
      if (_height>180)
      {
        iheight=180;
        _percent=_height/iheight
        iwidth=_width/_percent;
      }else if(_width>180)
          {
            iwidth=180;
            _percent=_width/iwidth
            iheight=_height/_percent;
          }  
    }
    //Variable of Alert
    var alertTimeout=0;
	var alertActiveMenu=null;
	var alertActiveButton=null;
    function OnOverAlert(button,text,w,h,p){
		//neu alertActiveButton da duoc kick hoat
			if (alertActiveButton!=null) alertActiveButton.className="btOff";
		//neu ActiveMenu ton tai (khac rong)
			if (alertActiveMenu!=null) alertActiveMenu.style.display="none";
			clearTimeout(alertTimeout);
			alertActiveButton=button;
			alertActiveButton.className="btOn"; 
			alertActiveMenu=document.getElementById(alertActiveButton.id + 'Item');			
			_text=document.getElementById('textView');			
			if (alertActiveMenu!=null)	{
				alertActiveMenu.style.display="block"; 
				alertActiveMenu.style.left = getRealLeft(button)- 5.7*button.width - alertActiveMenu.width-6-p;
				alertActiveMenu.style.top = getRealTop(button)-alertActiveMenu.height+button.height - 1;
				alertActiveMenu.style.height=h;
				alertActiveMenu.style.width=w;
				_text.innerHTML=text;
			}
	}
	function OnOffAlert(){
			alertTimeout=setTimeout("OffAlert()",200);
	}
    function OffAlert(){
		if(alertActiveButton != null) alertActiveButton.className ="btOff";
		if(alertActiveMenu != null) alertActiveMenu.style.display="none";
		alertActiveButton = null;
	    alertActiveMenu = null;
	}
	function changeClassName(id, clsname)
	{
		var _objDiv= document.getElementById(id);
		_objDiv.className=clsname
	}

	function insertMyImage(src)
	{
		if (confirm('Bạn chắc muốn chọn ?'))
		{
		    var a=prompt('Nhập vào độ dài ảnh','200');
			var sHTML = "<img src='"+src+"' width='"+a+"'>";
			dialogArguments.oUtil.obj.saveForUndo();
			var obj=dialogArguments.oUtil.obj;
			//alert("fgf"+obj.toString());
			obj.insertHTML(sHTML);
		}
		//return false;
		self.parent.close();
	}	
	function changeClassName(id, clsname)
	{
		var _objDiv= document.getElementById(id);
		_objDiv.className=clsname
	}
    function select(){
        return confirm('Bạn chắc muốn chọn ?');
    }
    function AddRemove(Source,Dest)
	{
		var SourceTmp=document.all(Source);
		var DestTmp=document.all(Dest); 
		var i;
		for(i=0; i<SourceTmp.options.length;i++)
		{
			if (SourceTmp.options[i].selected)
				{
					
					var optTmp=new Option();
					optTmp.text=SourceTmp.options[i].text;
					optTmp.value=SourceTmp.options[i].value;
					DestTmp.add(optTmp);
				}
		} 
		selectAll(Dest);
		var Len=SourceTmp.options.length-1;
		while(Len>=0)
		{
            if(SourceTmp.options[Len].selected)
				SourceTmp.remove(Len) ;
			Len--;
		}
		
    }
	function selectAll(id)
	{
		var DestTmp;
		DestTmp= document.all(id); 
		var i;
		for (i=0; i< DestTmp.options.length;i++)
		{
			DestTmp.options[i].selected=true;
		}
		if( DestTmp.options.length<1)
		  {
			alert('Bạn chưa chọn sản phẩm !');
			return false
		  }
		else
		{
			return true;
		}
	}